home *** CD-ROM | disk | FTP | other *** search
- Path: dsi.unimi.it!moreld
- From: moreld@dsi.unimi.it (~ZIO BUDDA~)
- Newsgroups: comp.lang.c++
- Subject: Re: How to write header file ?
- Date: 26 Feb 1996 15:03:30 GMT
- Organization: Computer Science Dep. - Milan University
- Message-ID: <4gsi42$rbp@tic.sm.dsi.unimi.it>
- References: <312D4B94.7957@hkein.school.net.hk>
- NNTP-Posting-Host: tac.fddi.dsi.unimi.it
- X-Newsreader: TIN [version 1.2 PL2]
-
- K. W. Kwok (kwkwok5@hkein.school.net.hk) wrote:
- > Hello everybody:
- > Can you tell me that how to write a
- > header file ? I want to link a external
- > subprogram (a set functions)with a main
- > program. They stored in different file (*.cpp).
- > Can I include a header file in main program to
- > call this subprogram ? If yes, how to do it ?
- > Can you slove my problems ?
- > Thank you very much!
-
- > You can reply me by e-mail directly.
- > My e-mail address is kwkwok5@hkein.school.net.hk
- > Thanks!
-
- > Bye
- > Wing
- have U tried to make this :
-
- ----main.c----
- #include <stdio.h>
- #include <stdlib.h>
- #include <what_do_U_need>
-
- extern void Subprogram1(argument_list);
- extern void Subprogram2(argument_list);
-
- main(int argc, char **argv)
- { int a;
- char c;
-
- ...
- Subprogram1(argument_list);
- ...
- Subprogram2(argument_list);
- ...
-
- };
- ---end main.c---
-
- ---Subprogram2.c---
- #include <stdio.h>
- #include <stdlib.h>
- #include <what_do_U_need>
-
- void Subprogram1(argument_list)
- {
- [code]
- };
-
- ---end Subprogram2.c---
-
- Idem for Subprogram1
-
- gcc -o main.o -c main.c
- gcc -o Subprogram2.o -c Subprogram2.c
- gcc -o Subprogram1.o -c Subprogram1.c
- gcc -o pippo main.o Subprogram1.o Subprogram2.o
-
- this (if I have no make kistake) work for gnu cc. If U use Borland C++ create a project and
- make the 3 files in the project files and It works in the same way.
-
-
-
- --
- Zio Budda "sempre alla ricerca di un account..." moreld@ghost.dsi.unimi.it
- http://www.dsi.unimi.it/Users/Students/moreld/home.html
- Ask me for questions about LINUX and Games for PC, and see my home page
- I'm a programmer and a consultant...
-
- Tel. 02/2139959 ... Chiedere di Davide Michel
-